import { Base } from '../../utils/base.js';

class JqOrderdetail extends Base {
  constructor() {
    super();
  }

  getjqQuery(oid, aid, callBack) {
    var param = {
      url: 'getjqQuery?oid=' + oid + '&aid=' + aid,
      sCallBack: function (data) {
        // console.log(data)
        callBack && callBack(data);
      }
    };
    this.request(param);
  }

  getJqStatus(oid, callBack) {
    var param = {
      url: 'getJqStatus?oid=' + oid,
      sCallBack: function (data) {
        console.log(data);
        callBack && callBack(data);
      }
    };
    this.request(param);
  } //支付


  execPay(orderID, callBack) {
    var param = {
      url: 'Jq/JQ_order',
      type: 'post',
      data: {
        id: orderID
      },
      sCallBack: function (res) {
        console.log(res);
        var timeStamp = res.timeStamp;

        if (timeStamp) {
          //可以支付
          tt.requestPayment({
            'timeStamp': timeStamp.toString(),
            'nonceStr': res.nonceStr,
            'package': res.package,
            'signType': res.signType,
            'paySign': res.paySign,
            success: function (res) {
              console.log(res);
              callBack && callBack(1);
            },
            fail: function () {
              callBack && callBack(0);
            }
          });
        } else {
          callBack && callBack(0);
        }
      }
    };
    this.request(param);
  }

}

export { JqOrderdetail };